//最大子数组和

class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int pre = nums[0];
        int ret = nums[0];
        for(int i = 1;i < nums.size(); i++)
        {
            pre = max(nums[i], pre + nums[i]);
            if(pre > ret) ret = pre;
        }
        return ret;
    }
};